package com.decheng.dao.impl;

import com.decheng.dao.OrderDao;
import com.decheng.dao.base.BaseDao;
import com.decheng.pojo.Order;
import com.decheng.utils.JDBCUtil;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * @Author 孔德成
 * @Slogan 致敬大师，致敬未来的你
 */
public class OrderDaoImpl extends BaseDao<Order> implements OrderDao {
    /**
     * 添加订单
     *
     * @param order
     */
    @Override
    public void saveOrder(Order order) {
        Connection conn = null;
        try {
            conn = JDBCUtil.getConnectionWithDruid();
            String sql = "insert into t_order values(?,?,?,?,?,?,?)";
            this.update(conn, sql,
                    order.getOrderId(),
                    order.getOrderSequence(),
                    order.getCreateTime(),
                    order.getTotalCount(),
                    order.getTotalAmount(),
                    order.getOrderStatus(),
                    order.getUserId());
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            JDBCUtil.closeResource(conn);
        }
    }
}
